package com.xz.group12306.servlet;

import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.xz.group12306.business.service.ManagerService;
import com.xz.group12306.business.service.impl.ManagerServiceImpl;
import com.xz.group12306.domain.Ticket;


/**
 * 顾赛男 管理员删除车票Servlet      
 */

@WebServlet("/ManageDelTicketServlet")
public class ManageDelTicketServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * 构造方法
	 */
	public ManageDelTicketServlet() {
		super();
	}

	/**
	 * @doGet方法
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//response.getWriter().append("Served at: ").append(request.getContextPath());
		String TicketID = request.getParameter("TicketID");
		ManagerService managerService=new ManagerServiceImpl();
		managerService.delTicket(Integer.parseInt(TicketID));
		
		
		List<Ticket> tickets = managerService.findAllTicket();
		HttpSession session = request.getSession();

		session.setAttribute("tickets", tickets);
		response.sendRedirect("admin/UpdateTicket.jsp");
		
		
	}

	/**
	 * doPost方法 
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
